/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Location style. We can set the style on specialized location without setting its value
	/// </summary>
	public class EQLocationStyle: EQRangeBase  	
	{
		private int mTop = DefaultInt;
		private int mBottom = DefaultInt;
		private int mLeft = DefaultInt;
		private int mRight = DefaultInt;
		private EQStyleBaseCollection mStyle = new EQStyleBaseCollection();


		/// <summary>
		/// Set/Get style collection
		/// </summary>
		public EQStyleBaseCollection Style
		{
			get
			{
				return this.mStyle;
			}
		}

		/// <summary>
		/// Set/Get first row index
		/// </summary>
		public int Top
		{
			get
			{
				return this.mTop;
			}
			set
			{
				this.mTop = EQKit.CheckPosition(value);
			}
		}

		/// <summary>
		/// Set/Get last row index
		/// </summary>
		public int Bottom
		{
			get
			{
				return this.mBottom;
			}
			set
			{
				this.mBottom = EQKit.CheckPosition(value);
			}
		}

		/// <summary>
		/// Set/Get last column index
		/// </summary>
		public int Right
		{
			get
			{
				return this.mRight;
			}
			set
			{
				this.mRight = EQKit.CheckPosition(value);
			}
		}

		/// <summary>
		/// Set/Get first column index
		/// </summary>
		public int Left
		{
			get
			{
				return this.mLeft;
			}
			set
			{
				this.mLeft = EQKit.CheckPosition(value);
			}
		}


		/// <summary>
		/// Initialize object for several cells
		/// </summary>
		/// <param name="top"></param>
		/// <param name="left"></param>
		/// <param name="bottom"></param>
		/// <param name="right"></param>
		public EQLocationStyle(int top, int left, int bottom, int right)
		{
			this.Top = top;
			this.Left = left;
			this.Bottom = bottom;
			this.Right = right;
		}

		/// <summary>
		/// Initialize object for a separate cell
		/// </summary>
		/// <param name="top"></param>
		/// <param name="left"></param>
		public EQLocationStyle(int top, int left)
		{
			this.Top = top;
			this.Left = left;
			this.Bottom = top;
			this.Right = left;
		}


		/// <summary>
		/// Output this object to excel document
		/// </summary>
		/// <param name="objWorksheet"></param>
		protected internal override void Output(Excel.Worksheet objWorksheet)
		{
			Excel.Range objRange = (Excel.Range)objWorksheet.get_Range(objWorksheet.Cells[this.Top, this.Left], objWorksheet.Cells[this.Bottom, this.Right]);
			this.Style.Output(objRange);
		}


		/// <summary>
		/// Add style. It's equal to using ".Style += style object"
		/// </summary>
		/// <param name="objEQStyleBase"></param>
		public void AddStyle(EQStyleBase objEQStyleBase)
		{
			this.Style.Add(objEQStyleBase);
		}
	}
}
